DEFINITION MODULE M2CM; (* HS 19.4.85; WH 9.5.85 *)


  FROM M2DM IMPORT ObjPtr, ParPtr;
  FROM M2HM IMPORT Item;

  CONST MaxExit = 15;  (* number of EXITs-1 per block *)

  TYPE LabelRange = RECORD low, high: INTEGER; label: CARDINAL END;
       ExitTable  = ARRAY [0..MaxExit] OF CARDINAL;

  VAR curPrio: CARDINAL;

  PROCEDURE GenAssign(VAR x, y: Item);

  PROCEDURE GenFJ(VAR loc: CARDINAL);  (* forward jump; loc := pc *)
  PROCEDURE GenCFJ(VAR x: Item; VAR loc: CARDINAL);
  PROCEDURE GenBJ(loc: CARDINAL);      (* backward jump to loc *)
  PROCEDURE GenCBJ(VAR x: Item; loc: CARDINAL);

  PROCEDURE PrepCall(VAR x: Item; VAR fp: ParPtr; VAR regs: LONGINT);
  PROCEDURE GenParam(VAR ap: Item; f: ParPtr);
  PROCEDURE GenCall(VAR x: Item; regs: LONGINT);
  PROCEDURE GenEnter(VAR l: CARDINAL; lev: CARDINAL);
  PROCEDURE GenResult(VAR x: Item; proc: ObjPtr; VAR l: CARDINAL);
  PROCEDURE GenReturn(proc: ObjPtr; l: CARDINAL);

  PROCEDURE GenCase1(VAR x: Item; VAR l0: CARDINAL);
  PROCEDURE GenCase2;
  PROCEDURE GenCase3(VAR x: Item; l0, l1, n: CARDINAL;
                     VAR tab: ARRAY OF LabelRange);

  PROCEDURE GenFor1(v: Item; VAR e1: Item);
  PROCEDURE GenFor2(v: Item; VAR e1, e2: Item);
  PROCEDURE GenFor3(v: Item; VAR e2, e3: Item; VAR l0, l1: CARDINAL);
  PROCEDURE GenFor4(v: Item; VAR e2, e3: Item; l0, l1: CARDINAL);

  PROCEDURE GenLoop1(VAR s, m: CARDINAL; n: CARDINAL);
  PROCEDURE GenLoop2(s, m: CARDINAL; VAR n: CARDINAL; VAR tab: ExitTable);
  PROCEDURE GenExit(VAR n: CARDINAL; VAR tab: ExitTable);

  PROCEDURE GenEnterMod(modList: ObjPtr; mno, pno: CARDINAL);
  PROCEDURE GenExitMod;

END M2CM. (* Copyright Departement Informatik, ETH Zuerich, Switzerland, 1992 *)
